onEventFlow

fun <T> SocketEvents.onEventFlow(socket: Socket, evaluation: (Any?) -> T): Flow<T>

Extension function to listen for a specific socket event and emit its data as a flow.

Return

A flow that emits the processed event data.

Example usage:

val messageFlow = socket.onEventFlow(SocketEvents.ON_MESSAGE) { it.toString() }

Parameters

T

The type of data to emit.

socket

The Socket instance to listen to.

evaluation

A function to process the received event data.